using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Data.Common;
using EntLibEC.Info.ECommerce;

namespace EntLibEC.Dac.ECommerce
{
    public class CooperationDac
    {
        public void Insert(CooperationInfo oParam)
        {
            Database db = DatabaseFactory.CreateDatabase();

            string sqlCommand = @"Insert into Ent_Cooperation(CooperationContent, CompanyName,
                CompanyURL, Address, Phone, Email, ContactPerson, Note, InCustomerSysNo)
                Values (@CooperationContent, @CompanyName, @CompanyURL, @Address,
                @Phone, @Email, @ContactPerson, @Note, @InCustomerSysNo) ";

            DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);

            db.AddInParameter(dbCommand, "CooperationContent", DbType.String, oParam.CooperationContent);
            db.AddInParameter(dbCommand, "CompanyName", DbType.String, oParam.CompanyName);
            db.AddInParameter(dbCommand, "CompanyURL", DbType.String, oParam.CompanyURL);
            db.AddInParameter(dbCommand, "Address", DbType.String, oParam.Address);
            db.AddInParameter(dbCommand, "Phone", DbType.String, oParam.Phone);
            db.AddInParameter(dbCommand, "Email", DbType.String, oParam.Email);
            db.AddInParameter(dbCommand, "ContactPerson", DbType.String, oParam.ContactPerson);
            db.AddInParameter(dbCommand, "Note", DbType.String, oParam.Note);
            db.AddInParameter(dbCommand, "InCustomerSysNo", DbType.Int32, oParam.InCustomerSysNo);

            db.ExecuteNonQuery(dbCommand);
        }
    }
}
